<?php
$this->breadcrumbs = array(
    ResourceType::$names[$type] =>  array('index', 'type'=>$type),
    '物理资源',
);
?>

<?php $this->widget('bootstrap.widgets.TbAlert'); ?>

<?php /** @var BootActiveForm $form */
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id'=>'job',
    'type'=>'search',
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
    ),
)); ?>

<script>
function reloadGrid(data) {
    $.fn.yiiGridView.update('physical-grid');
}
function checkSelect() {                                                  
    if($.fn.yiiGridView.getSelection("physical-grid") == "") {
        alert('请选择至少一条记录');                                                    
        return false;                                                  
    }
    else {
        return true;
    }
}
</script>

<div class="btn-toolbar">
<?php $this->widget('bootstrap.widgets.TbButton', array(
    'type'=>'danger',
    'buttonType'=>'ajaxSubmit',
    'size'=>'small',
    'icon'=>'remove white',
    'label'=>'删除物理资源', 
    'url'=>array('resource/ajaxDeletePhysical'), 
    'ajaxOptions'=>array(
        'beforeSend'=>  'checkSelect',
        'success'   =>  'reloadGrid',
    ),
    'htmlOptions'=>array(
        'confirm'=>'确认要删除吗?',
    ),

)); ?>

<?php $this->widget('bootstrap.widgets.TbButton', array(
    'type'=>'primary',
    'label'=>'新建物理资源',
    'icon'=>'plus white',
    'url'=>array('resource/createPhysical', 'type' => $_GET['type']),
    'size'=>'small',
     
)); ?>
</div>

<?php $this->widget('bootstrap.widgets.TbGridView', array(
	'id'=>'physical-grid',
    'type'=>'striped bordered condensed',
    'dataProvider'  =>  $dataProvider,
    'pager'=>array(
        'class'=>'CLinkPager',           
        'nextPageLabel'=>'下一页',           
        'prevPageLabel'=>'上一页',           
        'header'=>'',   
    ),   
    'selectableRows'=> 2,
    'summaryText'   =>  '显示{start}-{end}条.共{count}条记录,当前第{page}页',
    'template'      =>  '{items}{pager}',
    'columns'       =>  array(
       array(
       		'id'    =>  'autoId',
            'class' =>  'CCheckBoxColumn',
        ),
        array(
            'header'=>  '#',
            'name'  =>  'physical_id',
            'value' =>  '$data->physical_id'
        ),
       array(
            'name'  =>  'physical_name',
       		'type'	=>	'raw',
            'value' =>  'CHtml::link(CHtml::encode($data->physical_name), Yii::app()->controller->createUrl("resource/updatePhysical", array("id"=>$data->physical_id)))',
        ),
        array(
            'name'  =>  'res_id',
            'value' =>  '$data->resource->res_name'
        ),
        array(
            'name'  =>  'physical_type',
            'value' =>  'PhysicalType::$names[$data->physical_type]'
        ),
        array(
            'name'  =>  'storage',
            'value' =>  '$data->storage'
        ),
        array(
            'name'  =>  'keep_days',
            'value' =>  '$data->keep_days'
        ),
       
        array(
            'class' =>  'bootstrap.widgets.TbButtonColumn',
             'template'=>'{view}',           
             'buttons'=>array(
                 'view'  =>  array(
                     'label'    =>  '查看分区列表',
                     'url'      =>  'Yii::app()->controller->createUrl("resource/partition", array("id"=>$data->physical_id, "type"=>$_GET["type"]))',
                     ), 
                ),
        ),
    ),
));
?>
<?php $this->endWidget(); ?>
